<template>
  <div class="orderInfoCon">
      <van-divider
        :style="{ color: '#1989fa', borderColor: '#1989fa', padding: '0 16px' }"
        >
        即将购买
        </van-divider>
      <van-card
        :price="this.goods.goodsPrice"
        :title="this.goods.goodsName"
        :thumb="this.goods.goodsCoverImg"
      />
      <van-divider />
      <van-button type="primary" @click="buyNow">提交订单</van-button>
  </div>
</template>

<script>
export default {
    data() {
        return {
            goods: ''
        }
    },
    created() {
        this.getGoods()
    },
    methods: {
        getGoods() {
            this.goods = this.$route.params.goods
        },
        async buyNow() {
            const {data: res } =await this.$http.post('/api/order/addOrderForOneGoods',{goodsId: this.goods.goodsId})
            if (res.code !== 200) {
                this.$toast(res.msg)
                return 
            }
            const id = res.data
            this.$router.push({name:'pay',params:{orderId: id}})
        }
    }
}
</script>

<style lang="less" scoped>
.orderInfoCon {
    height: 712px;
    background-color: whitesmoke;
    margin-bottom: 50px;
    .van-button{
        width: 100%;
        position: relative;
    }
}
</style>